package com.ch.http.v1.impl;


import com.ch.http.v1.HttpServletImp;
import com.ch.http.v1.HttpServletRequest;
import com.ch.http.v1.HttpServletResponse;
import com.ch.http.v1.HttpSession;

import javax.servlet.annotation.WebServlet;
import java.io.PrintWriter;

@WebServlet("/myinfo.s")
public class getLoginedUserServlet extends HttpServletImp {

    public void doGet(HttpServletRequest request, HttpServletResponse response){
        response.setContentType("text/html;charset=utf-8");
        PrintWriter out = response.getWriter();
        HttpSession session = request.getSession();
        Object name = session.getAttribute("myinfo");
        if(name != null){
            out.append("请先登录!")
                    .append("<a href='login.html'>去登入</a>");
        } else {
            out.append("欢迎:").append(name.toString());
        }
    }
}
